# -*- coding: utf-8 -*-
# flake8: noqa
from qiniu import Auth, put_file_v2, etag
import qiniu.config


def qiniu_token():
    # 需要填写你的 Access Key 和 Secret Key
    access_key = '2edN6MlG_2Ob6mewZ1kq2NwLtydfu-ogNSseEkF5'
    secret_key = 'yeYO3zJ_sZLlqXiLTZT5AxbrjTaQQcOFoTVqV8rH'
    # 构建鉴权对象
    q = Auth(access_key, secret_key)
    # 要上传的空间
    bucket_name = 'project-huang'

    # print(f"Access Key: {access_key}")
    # print(f"Secret Key: {secret_key[:10]}...")
    # print(f"Bucket Name: {bucket_name}")

    # 生成上传 Token，可以指定过期时间等
    # 不指定key，让七牛云自动生成文件名
    token = q.upload_token(bucket_name, key=None, expires=3600)

    print(f"七牛云Token: {token}")
    return token

q = qiniu_token()
